﻿@using BlazorApp4.UIInterface;

<CascadingValue Value = "this">
    <ul class="nav nav-tabs">
        @ChildContent
    </ul>
</CascadingValue>

<div class="nav-tabs-body p-4">
    @ActiveTab?.ChildContent
</div>

@code {
    [Parameter]
    public RenderFragment ChildContent { get; set; }

    public ITab? ActiveTab { get; private set; }

    public void AddTab (ITab tab)
    {
        if (ActiveTab is null)
        {
            SetActiveTab(tab);
        }
    }

    public void SetActiveTab(ITab tab)
    {
        if (ActiveTab != tab)
        {
            ActiveTab = tab;
            StateHasChanged();
        }
    }

}
